/**
 * Created by willem
 */
import './index.scss';
import { PureComponent } from 'react';
import videojs from 'video.js';
import 'video.js/dist/video-js.css';
import T from 'utils/T';
import {

} from 'antd';
// const videoUrl = 'http://localhost:8365/static/ts/playlist.m3u8';
const videoUrl = 'http://localhost:8666/static/video/ts/3/live.m3u8';
// const videoUrl = 'http://chongqing.meteorology.com/static/video/C0002.mp4';
export default class Components extends PureComponent {
    constructor(props) {
        super(props);
        this.state = {};
    }

    componentDidMount() {
        const videoInstance = videojs('video-play', {
            controls: true,
            autoplay: true,
            preload: 'auto',
            loop: 'loop',
        });

        videojs.addLanguage('zh-CN', {
            'Play': '播放',
            'Pause': '暂停',
            'Current Time': '当前时间',
            'Duration Time': '时长',
            'Remaining Time': '剩余时间',
            'Stream Type': '媒体流类型',
            'LIVE': '直播',
            'Loaded': '加载完毕',
            'Progress': '进度',
            'Fullscreen': '全屏',
            'Non-Fullscreen': '退出全屏',
            'Mute': '静音',
            'Unmute': '取消静音',
            'Playback Rate': '播放码率',
            'Subtitles': '字幕',
            'subtitles off': '字幕关闭',
            'Captions': '内嵌字幕',
            'captions off': '内嵌字幕关闭',
            'Chapters': '节目段落',
            'You aborted the media playback': '视频播放被终止',
            'A network error caused the media download to fail part-way.': '网络错误导致视频下载中途失败。',
            'The media could not be loaded, either because the server or network failed or because the format is not supported.': '视频因格式不支持或者服务器或网络的问题无法加载。',
            'The media playback was aborted due to a corruption problem or because the media used features your browser did not support.': '由于视频文件损坏或是该视频使用了你的浏览器不支持的功能，播放终止。',
            'No compatible source was found for this media.': '无法找到此视频兼容的源。',
            'The media is encrypted and we do not have the keys to decrypt it.': '视频已加密，无法解密。',
            "Failed to execute 'appendBuffer' on 'SourceBuffer': The SourceBuffer is full, and cannot free space to append additional buffers.": '未能在SourceBuffer上执行‘appendBuffer’:SourceBuffer已经满了，不能释放空间来追加额外的缓冲区。'
        });


    }


    render() {
        return (<div>


            <video
                id={`video-play`}
                controls
                className="video-js vjs-default-skin vjs-big-play-centered"
                preload="auto"
                data-setup='{}'
                width={320}
                height={180}
                poster={''}
            >
                <source
                    src={videoUrl}
                    // type="application/x-mpegURL"
                />
                <a href="https://vjs.zencdn.net/7.3.0/video-js.css" target="_blank"></a>

            </video>

        </div>);
    }
}

